<?php
session_start();
include "Includes/solotrn_sesion.php";
include "Includes/soloFun_Generales.php";

$fecha1 = date('m/d/Y');
$CboNodo = $_REQUEST["CboNodo"];
$valida = "ValidaDatos()";
$opcion = $_REQUEST["Opcion"];
$usu = $_REQUEST["usuario"];
$cod_dpto = $_REQUEST["cod_dpto"];

switch ($opcion) {
    case 1:
        $imagen = "iconos/soloico_grabar.gif";
        $Oculto = "<input type='hidden' name='Opcion' value=1>";
        //'sql="select co_perf from solotb_usuario where nu_usua='" & CboNodo & "'"
        //'rw"",sql
        break;
    case 2:
        $imagen = "iconos/soloico_eliminar.gif";
        $Oculto = "<input type='hidden' name='Opcion' value=2>";
        break;
    case 3:
        $imagen = "iconos/soloico_grabar.gif";
        $Oculto = "<input type='hidden' name='Opcion' value=3>";
        //'rw"",$_REQUEST["max")
        //$SoloSQL = "select (count(codigo)+1) as maximo from tb_soporte";
        //$Maximo = EjecutaSentenciaSql($SoloSQL);
        break;
}
$XtxtAutor = $_SESSION["no_usua"];
$txtId = $_REQUEST["txtId"];

$administrador = $_REQUEST["administrador"];
$CboSoporte = $_REQUEST["CboSoporte"];

$soloSQL2 = "select co_usua, no_usua from solotb_usuario where nu_usua = $administrador";
$rowAdmin = soloFun_ExecSQL ($soloSQL2,$SoloArrSoporte2);

$soloSQL2 = "select c.co_usua, c.no_usua from tb_soporte a left join solotb_usuario c on a.nu_usua = c.nu_usua where cod_dpto = $cod_dpto";
//echo $soloSQL2;
soloFun_ExecSQL ($soloSQL2,$SoloArrSoporte);
//printArray($SoloArrSoporte);
//printArray($SoloArrSoporte2);
$SoloArrSoporte = @array_merge($SoloArrSoporte2, $SoloArrSoporte);

$StrCboSoporte = SoloFun_CargaCombo($SoloArrSoporte,"CboSoporte","",$CboSoporte," style='width: 180px' class='SoloStyle_Texto' ", "B");
//On error resume next
?>
<html>
    <head>
        <title>Mensaje</title>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
        <link href="SoloStyles/Solostyles.css" rel="stylesheet" type="text/css">
        <SCRIPT type="text/JavaScript" src="Includes/Solofun_generales.js"></SCRIPT>
    </head>
    <body topmargin="0" leftmargin="0" onkeydown="checkKey();">
        <table cellpadding="0" cellspacing="0" style="width: 90%">
            <tr>
                <td><img src="templates/SoloTemplate_LogoCabecera.png" style="height: 50px" alt=""/></td>
                <td style="text-align:center" class="SoloStyle_TituloPaginas">Agregar Mensaje</td>
            </tr>
        </table>
        <form enctype="multipart/form-data" name="frm" action="solotrn_Grabarmensaje.php?txtId=<?php echo $txtId;?>" method="POST">
            <?php echo $Oculto;?>
            <table border="0" width="90%" align="center" cellpadding="2" cellspacing="1" bordercolor="#CCCCCC">
                <tr>
                    <td><img src="iconos/soloico_salir.gif" border="1" alt="Regresar" style="cursor:hand" onClick="window.opener.location.reload(); window.close();" >
                        <img src="<?php echo $imagen?>" border="1" alt="Grabar" style="cursor:hand" onClick="<?php echo $valida;?>;"></td>
            </table>
            <table border="0" width="90%" bordercolor="#CCCCCC" cellpadding="2" cellspacing="1" align="center">
                    <tr>
                        <td width="20%" class="SoloStyle_Etiqueta">ID Ticket</td>
                        <td width="80%" class="SoloStyle_Grid"> <input type="text"  name="txtId" size="21" maxlength="50" class="SoloStyle_Texto" value="<?php echo $txtId;?>" readonly="true">      </td>
                    </tr>
                    <tr>
                        <td class="SoloStyle_Etiqueta">Fecha</td>
                        <td  class="SoloStyle_Grid"> <input type="text"  name="fecha" size="21" maxlength="50" class="SoloStyle_Texto" value="<?php echo date("d/m/Y");?>" readonly="true"></td>
                    </tr>
                    <tr>
                        <td class="SoloStyle_Etiqueta">Autor</td>
                        <td  class="SoloStyle_Grid">
                            <input name="XtxtAutor" <?php //'readonly="true"?> type="text" class="SoloStyle_Texto" OnKeyPress="Lock_Field(this)" value="<?php echo $XtxtAutor;?>" size="40" maxlength="50"  onKeyDown="return tabOnEnter(this,event);" readonly>
                            *      </td>
                    </tr>
                    <tr>
                        <td class="SoloStyle_Etiqueta">Para</td>
                        <td  class="SoloStyle_Grid">
                            <?php if(isset($StrCboSoporte)) {
                                echo $StrCboSoporte;
                            }else {
                                ?>
                            <input name="XtxtTecnico" <?php //'readonly="true"?> type="text" class="SoloStyle_Texto" OnKeyPress="Lock_Field(this)" value="<?php echo $XtxtTecnico;?>" size="40" maxlength="50"  onKeyDown="return tabOnEnter(this,event);" readonly="true">
                            *<?php }?>
                        </td>
                    </tr>
                    <tr>
                        <td class="SoloStyle_Etiqueta">Mensaje</td>
                        <td  class="SoloStyle_Grid">
                            <textarea name="XtxtMensaje" cols="41" rows="3" class="SoloStyle_Texto" <?php echo $disabledad;?> tabindex="7"><?php echo $XtxtMensaje;?></textarea>
                            *      </td>
                    </tr>
                    <tr>
                        <td class="SoloStyle_Etiqueta">Adjuntar</td>
                        <td  class="SoloStyle_Grid">
                            <input name="XtxtArchivo" <?php //'readonly="true"?> type="file" class="SoloStyle_Texto" OnKeyPress="Lock_Field(this)" value="<?php echo $XtxtArchivo;?>" size="40" maxlength="50"  onKeyDown="return tabOnEnter(this,event);" readonly="true">
                        </td>
                    </tr>
                </table>
            <!--<table border="0" width="90%" bordercolor="#CCCCCC" cellpadding="2" cellspacing="1" align="center">
                <tr>
                    <td class="SoloStyle_Etiqueta" width="25%">Ticket Id: </td>
                    <td width="75%" class="SoloStyle_EtiquetaCajas" align="left">
                        <input type="text" maxlength="50" size="43" name="id" class="SoloStyle_Texto" value="<?php echo $_REQUEST["txtId"];?>" readonly="true" align="left">
                    </td>
                </tr>
                <tr>
                    <td class="SoloStyle_Etiqueta" width="25%">Autor</td>
                    <?php
                    if ($opcion == 3)
                        $Codigo = $Maximo;
                    else
                        $Codigo = $arrUsuario[0][0];
                    ?>
                    <td class="SoloStyle_EtiquetaCajas" width="75%" align="left">
                        <input type="text" maxlength="50" size="43" name="ATxtUsuario" id="ATxtUsuario" class="SoloStyle_Texto" value="<?php echo $_SESSION["co_usua"];?>" readonly="true" align="left">
                    </td>
                </tr>
                <tr>

                    <td class="SoloStyle_Etiqueta">Descripci&oacute;n</td>
                    <td class="SoloStyle_EtiquetaCajas" align="left">
                        <textarea name="ATxtDescripcion" id="ATxtDescripcion" class="SoloStyle_Texto" cols="45" rows="4"> </textarea>
                    </td>
                </tr>
                <tr>
                    <td class="SoloStyle_Etiqueta">Fecha referencia</td>
                    <td class="SoloStyle_EtiquetaCajas" align="left">
                        <input name="fecha1" id="fecha1" type="text" class="SoloStyle_Texto"  value="<?php echo date('d/m/Y');?>" size="12" maxlength="10" readonly="true" >
                        <a href="javascript:ShowCalendar(document.all.dateimg1a,document.all.fecha1,null, '16/1/2008', '16/1/2017')" onClick="event.cancelBubble=true;">
                            <img align=top border=0 height=21 id="dateimg1a" src="Includes/Calendario/cal/calendar.gif" style="POSITION: relative" width=34></a>
                    </td>
                </tr>
                <tr>
                    <td class="SoloStyle_Etiqueta">Fecha Registro</td>
                    <td class="SoloStyle_EtiquetaCajas"><input type="text" maxlength="50" size="43" name="atxtfecharegistro" class="SoloStyle_Texto" value="<?php echo date('d/m/Y');?>" readonly="true" align="left"></td>
                </tr>
                <tr>
                    <td class="SoloStyle_Etiqueta">Adjuntar Archivo</td>
                    <td class="SoloStyle_EtiquetaCajas"><input name="txtarchivo1" type="file" value="Submit" size="25" <?php echo $DispBrowse1;?> <?php echo $disabledv;?> >
                        <a href="solotrn_EliminarAdjunto.php?archivo=archivo1&txtId=<?php echo $txtId;?>&opcion=<?php echo $opcion;?>"></a></td>
                </tr>
            </table>-->
            <br>
        </form>
    </body>
</html>
<script type="text/javascript">
    function ValidaDatos(){
        var destinatario = document.getElementsByName("CboSoporte")[0];

        if (destinatario.options[destinatario.selectedIndex].text == ""){
            alert ("Debe seleccionar destinatario");
            return false;
        }

        var mensaje = document.getElementsByName("XtxtMensaje")[0];
        if (mensaje.value == ""){
            alert ("Debe ingresar un mensaje");
            mensaje.focus();
            return false;
        }

        document.frm.submit();
    }

    function novalida(){
        document.frm.submit();
    }

</script>
<!-- #include file="Includes/solofun_showmessages.asp"-->
